package com.javasm.dao.MisMannageDao.impl;



import com.javasm.dao.MisMannageDao.FeedBackDao;
import com.javasm.entity.MisMannageEntity.FeedBack;
import com.javasm.util.JDBCUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author:JAVASM
 * @description:
 * @date:2022/5/26 10:06
 * @version:0.1
 * @since:jdk11
 */
public class FeedBackDaoImpl implements FeedBackDao {
    @Override
    public Integer addFeedBack(FeedBack addFeedBack) {
        Connection conn = JDBCUtil.getConn();
        PreparedStatement ps = null;
        StringBuilder sb = new StringBuilder();
        sb.append("insert into tb_feedback(uid,troublelist,suggestion,contact,platform,os) values(?,?,?,?,?,?)");

        Integer addNum = 0;
        try {
            ps = conn.prepareStatement(sb.toString());
            ps.setInt(1,addFeedBack.getUid());
            ps.setString(2,addFeedBack.getTroubleList());
            ps.setString(3,addFeedBack.getSuggestion());
            ps.setString(4,addFeedBack.getContact());
            ps.setString(5,addFeedBack.getPlatform());
            ps.setString(6,addFeedBack.getOs());
            addNum = ps.executeUpdate();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtil.closeConn(conn, ps,null, null);
        }
        return addNum;
    }
}
